package com.meilai.project.controller.web.report.vo;

import cn.hutool.core.collection.CollUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDate;
import java.util.List;

/**
 * @author chenxing
 */
@Data
@ApiModel
public class AppWorkOrderCustomerProcessVO {

    @ApiModelProperty("工单id")
    private Long work_order_id;

    @ApiModelProperty("工单类型,全部时不传")
    private Integer work_order_type_id;

    @ApiModelProperty("工单类型名")
    private String work_order_type_name;

    @ApiModelProperty("客户id")
    private Long customerId;

    @ApiModelProperty("客户名称")
    private String customerName;

    @ApiModelProperty("执行时间段")
    private String customerTime = "";

    @ApiModelProperty("截止时间")
    private LocalDate deadline;

    @ApiModelProperty("已提交数量")
    private Long hasSubmitCount = 0L;

    @ApiModelProperty("未提交数量")
    private Long hasNotSubmitCount = 0L;

    @ApiModelProperty("是否已完成")
    private Boolean hasFinished;

    @ApiModelProperty("楼盘详情")
    private List<AppWorkOrderBuildingProcessVO> buildingProcessList;

    public void autoCalcCount(){
        if(CollUtil.isNotEmpty(buildingProcessList)) {
            hasSubmitCount = 0L;
            hasNotSubmitCount = 0L;
            for (AppWorkOrderBuildingProcessVO appWorkOrderBuildingProcessVO : buildingProcessList) {
                hasSubmitCount += appWorkOrderBuildingProcessVO.getHasSubmitCount();
                hasNotSubmitCount += appWorkOrderBuildingProcessVO.getHasNotSubmitCount();
            }
            hasFinished = hasNotSubmitCount == 0;
        }
    }

}
